pub mod dose_stat;
use numpy::{PyArray1, PyReadonlyArray1, ToPyArray};
use pyo3::prelude::*;

#[pyfunction]
fn accumulate(
    voxel_volume: PyReadonlyArray1<f64>,
    voxel_dose: PyReadonlyArray1<f64>,
    do_exact: bool,
) -> PyResult<(Py<PyArray1<f64>>, Py<PyArray1<f64>>)> {
    let vol = voxel_volume.as_slice().unwrap();
    let dose = voxel_dose.as_slice().unwrap();
    let ret = dose_stat::accumulate(vol, dose, do_exact);
    Python::attach(|py| {
        let doses = ret.binned_dose_values.to_pyarray(py).to_owned();
        let vols = ret.accumulated_relative_volumes.to_pyarray(py).to_owned();
        Ok((doses, vols))
    })
}

#[pymodule]
fn dose_statistics_py(_py: Python, m: &PyModule) -> PyResult<()> {
    m.add_function(wrap_pyfunction!(accumulate, m)?)?;
    Ok(())
}
